package migrations

import (
	"github.com/goravel/framework/contracts/database/schema"
	"github.com/goravel/framework/facades"
)

type M20250701093159CreateSysMenusTable struct {
}

// Signature The unique signature for the migration.
func (r *M20250701093159CreateSysMenusTable) Signature() string {
	return "20250701093159_create_sys_menus_table"
}

// Up Run the migrations.
func (r *M20250701093159CreateSysMenusTable) Up() error {
	if !facades.Schema().HasTable("sys_menu") {
		return facades.Schema().Create("sys_menu", func(table schema.Blueprint) {
			table.ID()
			table.Integer("type").Default(0).Comment("菜单类型")
			table.String("name").Comment("菜单名称")
			table.Integer("parent_id").Default(0).Comment("父级ID")
			table.Integer("order_num").Default(0).Comment("排序")
			table.String("path").Comment("路由路径")
			table.String("component").Comment("组件路径")
			table.String("query_params").Comment("路径参数")
			table.String("icon").Comment("图标")
			table.Integer("is_frame").Default(0).Comment("是否内嵌")
			table.Integer("is_cache").Default(0).Comment("是否缓存")
			table.Integer("visible").Default(0).Comment("是否显示")
			table.TimestampsTz()
		})
	}

	return nil
}

// Down Reverse the migrations.
func (r *M20250701093159CreateSysMenusTable) Down() error {
	return facades.Schema().DropIfExists("sys_menu")
}
